//
//  StockInfoTableViewCell.m
//  StockNet
//
//  Created by 小焘无量 on 2023/1/6.
//

#import "StockInfoTableViewCell.h"
#import "LoginViewController.h"

@interface StockInfoTableViewCell()

@property (weak, nonatomic) IBOutlet UILabel *nameLab;// 名称
@property (weak, nonatomic) IBOutlet UILabel *specLab;// 规格
@property (weak, nonatomic) IBOutlet UILabel *materialLab;// 材质
@property (weak, nonatomic) IBOutlet UILabel *numLab;// 数量
@property (weak, nonatomic) IBOutlet UILabel *placeLab;// 产地
@property (weak, nonatomic) IBOutlet UILabel *companyLab;// 公司
@property (weak, nonatomic) IBOutlet UILabel *timeLab;// 更新时间

@property (weak, nonatomic) IBOutlet UIButton *callPhoneBtn;

@end

@implementation StockInfoTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.callPhoneBtn.backgroundColor = kThemeColor;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (IBAction)callBtnAction:(id)sender {
    
    if (![YTClient shared].isLogin) {
        [[YTClient shared] presentLoginControllerFrom:[NSObject getCurrentViewController] showClose:YES];
        return;
    }
    
    if (![YTClient shared].isMember) {
//        [MBProgressHUD showMessage:@"请先开通会员"];
//        [ChosePayTypeView showComplate:^(NSString * _Nonnull payType) {
//            [UIAlertController alertWithController:[NSObject getCurrentViewController] title:nil message:@"请联系销售:13788932357" actionTitles:@[@"取消", @"确定"] actionOne:nil actionTwo:^{
//                NSString *str = @"telprompt://13788932357";
//                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str] options:@{} completionHandler:nil];
//            }];
//        }];
        
        [NSObject getCurrentViewController].tabBarController.selectedIndex = 1;
        
    } else {
        NSString *str = [NSString stringWithFormat:@"telprompt://%@", self.model.phone];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str] options:@{} completionHandler:nil];
        
        [[APIManager manager] Get:URL_InquiriesTimes parameters:nil success:nil failure:nil];
    }
    
}

-(void)setModel:(InstockListModel *)model {
    _model = model;
    
    self.nameLab.text = model.varieties;
    self.specLab.text = model.spec;
    self.materialLab.text = model.textureMaterial;
    
    self.numLab.text = FormatString(@"%@件", model.quantity);
    self.placeLab.text = FormatString(@"产地：%@", model.place);
    self.companyLab.text = FormatString(@"公司简称：%@",model.company);
    
    self.timeLab.text = model.updateTime;
}

@end
